<?php
include_once("../includes/global.php");
$script_tmp = explode('/', $_SERVER['SCRIPT_NAME']);
$sctiptName = array_pop($script_tmp);
@include_once("auth.php");
//=========================================
$type='module_company';
if(!empty($_POST['submit'])&&$_POST["submit"]==lang_show('submit'))
{
	unset($_POST['submit']);
	foreach($_POST as $pname=>$pvalue)
	{
		$sql="select * from ".CONFIG." where `index`='$pname' and type='$type'";
		$db->query($sql);
		if($db->num_rows())
		   $sql1=" update ".CONFIG." SET value='$pvalue',type='$type' where `index`='$pname'";
		else
		   $sql1="insert into ".CONFIG." (`index`,value,type) values ('$pname','$pvalue','$type')";
		$db->query($sql1);
	}
	/****更新缓存文件*********/
	$write_config_con_array=read_config($type);//从库里取出数据生成数组
	$write_config_con_str=serialize($write_config_con_array);//将数组序列化后生成字符串
	$write_config_con_str=str_replace("'","\'",$write_config_con_str);
	$write_config_con_str='<?php $'.$type.'_config = unserialize(\''.$write_config_con_str.'\');?>';//生成要写的内容
	$fp=fopen('../config/'.$type.'_config.php','w');
	fwrite($fp,$write_config_con_str,strlen($write_config_con_str));//将内容写入文件．
	fclose($fp);
	/*********************/
	admin_msg("module.php?m=company&s=module_config.php","设置成功");
	exit;
}
//===读库函数，生成config形式的数组====
function read_config($type)
{
	global $db;
	$sql="select * from ".CONFIG." where type='$type'";
	$db->query($sql);
	$re=$db->getRows();
	foreach($re as $v)
	{
		$index=$v['index'];
		$value=$v['value'];
		$configs[$index]=$value;
	}
	return $configs;
}
$reg_config=read_config($type);
if(!$reg_config)
{
	@include('config/'.$type.'_config.php');
	$con=$type.'_config';
	$reg_config=$$con;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<TITLE><?php echo lang_show('admin_system');?></TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
<link href="main.css" rel="stylesheet" type="text/css" />
<script src="../script/prototype.js" type=text/javascript></script>
</head>
<body>
<div class="guidebox"><?php echo lang_show('system_setting_home');?> &raquo; <?php echo lang_show('sysconfig');?></div>
<div class="bigbox">
	<div class="bigboxhead">模块配置</div>
	<div class="bigboxbody">
	<form name="sysconfig" action="" method="post" style="margin-top:0px;">
	<table width="100%" cellspacing="0">
	   <tr class="theader"><td colspan="2">SEO</td></tr>
		   <tr>
			  <td width="17%"  align="left" >Title</td>
			  <td align="left" >
			  <input class="text" name="title" type="text" id="title" value="<?php echo $reg_config['title'];?>" size="10"></td>
			</tr>
                <tr>
                  <td height="40" align="left">Keyword</td>
                  <td align="left" ><input class="text" name="keyword" type="text" id="keyword" size="10" value="<?php echo $reg_config['keyword'];?>"></td>
                </tr>
                <tr>
                  <td height="40" align="left"><pre id="line1">Description</pre></td>
                  <td align="left" ><textarea name="description" cols="10" rows="3" class="text" id="description"><?php echo $reg_config['description'];?></textarea></td>
                </tr>
                <tr class="theader">
                  <td height="23" colspan="2" >会员中心</td>
                </tr>
                <tr>
                  <td height="40" align="left">会员身份 </td>
                  <td align="left" ><input name="identity" type="text" class="text" value="<?php echo $reg_config['identity'];?>" />
				  <span class="bz"><br />
				  此项设置用于较大型网站，会员结构复杂。如建材网，建材商，设计师，装修公司。<br />
				  普通B2B网站请将此项设置为。<br />
				  请勿轻易修改，不然会导致会员身份错乱。</span>
				  </td>
                </tr>
                <tr>
                  <td height="40" align="left">公司类型</td>
                  <td align="left" ><input class="text" name="companyType" type="text" id="companyType" size="10" value="<?php echo $reg_config['companyType'];?>">
                    <br /><span class="bz">
                    生产型|贸易型|服务型|代理型|政府或其他机构<br />
                  Production|Trade|Service-oriented|Agent-based|The government or other agencies</span></td>
                </tr>
                <tr>
                  <td height="40" align="left">是否展示业务范围</td>
                  <td align="left" ><input name="display_cat" type="text" id="display_cat" size="10" value="<?php echo $reg_config['display_cat'];?>">
                  <span class="bz">填 1表示是。或0表示非</span></td>
                </tr>
                <tr class="theader">
                  <td height="26" colspan="2" >企业频道首页</td>
                </tr>
                <tr>
                  <td height="40" align="left">最新注册会员显示条数</td>
                  <td align="left" ><input name="new_user" type="text" id="new_user" size="10" value="<?php echo $reg_config['new_user'];?>"></td>
                </tr>
                <tr>
                  <td height="40" align="left">明星企业显示条数</td>
                  <td align="left" ><input name="rec_user_num" type="text" id="rec_user_num" size="10" value="<?php echo $reg_config['rec_user_num'];?>"></td>
                </tr>
        <tr>
          <td width="17%" height="40" align="right">&nbsp;</td>
          <td align="left" ><input  class="btn" type="submit" name="submit" value="<?php echo lang_show('submit');?>"></td>
        </tr>
      </table>
	</form>
	</div>
</div>
</body>
</HTML>